<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> 
		<link rel="stylesheet" href="css/common.css" />
		<link rel="stylesheet" href="css/set.css" />
		
		<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
		<script type="text/javascript" src="js/angular.min.js" ></script>
		<script type="text/javascript" src="js/global.js"></script>
		<title>设置</title>
	</head>
	<body>
	<header>
		<span class="return"><a href="javascript:void(0)" onclick="javascript :history.go(-1)"><img src="image/返回.png"></a></span>
		<span class="findPassword_header">设置</span>
	</header>
	<div class="container" ng-app="myApp" ng-controller="myCtrl" ng-cloak>
		<div class="about">
			<ul>
				<li ng-click="toLogin()">
					<span>登录</span>
					<span><img src="image/形状 2 拷贝 3.png"></span>
				</li>
				<li ng-click="toSign()">
					<span>注册</span>
					<span><img src="image/形状 2 拷贝 3.png"></span>
				</li>
				<li ng-click="toChange()">
					<span>修改密码</span>
					<span><img src="image/形状 2 拷贝 3.png"></span>
				</li>
				<li ng-click="toLogout()">
					<span>注销登录</span>
					<span><img src="image/形状 2 拷贝 3.png"></span>
				</li>
			</ul>
			<!--提示框-->
			<div class="alert" ng-show="reminder"></div>
			<div class="reminder" ng-show="reminder">
				<p>温馨提示</p>
				<p>{{ message }}</p>
				<p ng-click="close()">确定</p>
			</div>
		</div>
			
	</div>
	<script type="text/javascript">
	    var app = angular.module("myApp",[]);
	    app.controller("myCtrl",function($scope,$http){
	    	$scope.reminder = false;
	    	$scope.close = function(){
	    		$scope.reminder = false;
	    	}
	    	//用户登录
            $scope.toLogin = function(){
            	if (window.sessionStorage.login == "true") {
            		$scope.reminder = true;
                    $scope.message = "用户已登录！";
            	}else{
                    window.location.href = 'login.html';
            	}
            }
            //用户注册
            $scope.toSign = function(){
            	window.location.href = 'sign.html';
            }
            //修改密码
            $scope.toChange = function(){
            	window.location.href = 'changePassword.html';
            }
            //注销用户
            $scope.toLogout = function(){
            	if (window.sessionStorage.login == "true") {
            		$http({
					    method : "post",
					    dataType: "json",
						withCredentials: true,	//跨域名请求。XHR：XMLHttpRequest (XHR) ，基于XML技术的Http请求
						crossDomain: true,
						headers:{'Content-Type': 'application/x-www-form-urlencoded'},
					    async:true,
					    url : host + "/terminal/user/logout"
					}).success(function(response){
						console.log(response);
						if(response.code == 2000){
	                        $scope.reminder = true;
	                        $scope.message = response.message
						}
					})
					window.sessionStorage.login = false;
            	}else{
                    $scope.reminder = true;
	                $scope.message = "用户未登录！";
            	}
                
            }
	    })
	</script>
	
	</body>
</html>